package com.it.jzs.controller;

import com.it.jzs.service.UserCollectionService;
import com.it.jzs.vo.Result;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;

@RestController
@RequestMapping("collection")
@CrossOrigin
public class UserCollectionController {

    @Resource
    private UserCollectionService collectionService;


//    @GetMapping("/type/{id}")// 博客分类列表页查询
//    public Result<Object> selectBlogTypeList(@PathVariable("id") Integer id) {
//        Result<Object> result = collectionService.selectBlogTypeList(id);
//        return result;
//
//    }

    @PostMapping("/{id}/{userId}")  // 通过博客id和收藏博客的用户id来新增
    public Result<Object> selectBlogTypeList(@PathVariable("id") Integer id, @PathVariable("userId") Integer userId) {
        Result<Object> result = collectionService.insert(id, userId);
        return result;

    }

    @GetMapping("/{id}/{userId}")// 通过博客id和收藏博客的用户id来 获取点赞状态
    public Result<Object> selectCollectionStatus(@PathVariable("id") Integer id, @PathVariable("userId") Integer userId) {

        Result<Object> result = collectionService.selectCollectionStatus(id, userId);
        return result;
    }

    @GetMapping("/{userid}")  // 根据用户id查询出所有的收藏记录
    public Result<Object> selectCollection(@PathVariable("userid") Integer userId) {


        Result<Object> result = collectionService.selectCollection(userId);
        return result;
    }
}
